﻿@using BV.PACS.WEB.Shared.Models
@using Microsoft.AspNetCore.Components

<button type="button" class="btn btn-link" @onclick="@OnClick">@Barcode</button>

@functions {

    [Parameter]
    public object Context { get; set; }

    [Parameter]
    public Action<string, int> OnCellClick { get; set; }

    private int Id => Context is SourceCatalogDto source ? source.SourceId : 0;
    private  string Barcode => Context is SourceCatalogDto source ? source.SourceBarcode : string.Empty;

    private async Task  OnClick()
    {
        if (Id > 0)
        {
            await InvokeAsync(()=>OnCellClick?.Invoke(nameof(SourceTrackingForm), Id));
        }
    }

}